package com.alog.storage.presenter;

import android.content.Context;
import com.alog.storage.Contants;
import com.alog.storage.net.AccountAPI;
import com.alog.storage.ui.activity.IBaseView;
import java.util.ArrayList;

/**
 * 帐户管理业务类
 */
public class AccountPresenterImpl<T> extends BasePresenter implements AccountPresenter {
    private AccountAPI mApi;

    public AccountPresenterImpl(Context context) {
        mApi = new AccountAPI(context, this);
        iView = (IBaseView) context;
    }

    /**
     * 登录
     *
     * @param mobilePhone
     * @param pwd
     */
    @Override
    public void login(String mobilePhone, String pwd) {

    }

    /**
     * 获取用户详情
     */
    @Override
    public void getUserDetail() {

    }

    @Override
    public void onSuccess(int apiId, Object data) {
        if (apiId == Contants.API_ID_LOGIN) {

        } else if (apiId == Contants.API_ID_GET_USERDETAIL) {
            ArrayList<Object> list = (ArrayList<Object>) data;
            if (list.size() == 0) {
                iView.showEmpty();
            } else {
                super.onSuccess(apiId, data);
            }
        }
    }

    /**
     * 取消网络请求
     */
    @Override
    public void cancelRequest() {
        mApi.cancelRequest();
    }

}
